package net.homeftp.heimo.weddingwidget.ui.imgdialog;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.ListAdapter;

public class ImageListDialog {
	private static final String TAG = "ImageListDialog";
	private OnImgListener mlistener = null;
	private Context mContext = null;
	private AlertDialog.Builder alert = null;
	private int imgArrayReference = 0 ;

	public ImageListDialog(Context context, OnImgListener mlistener,int imageArray) {
		this.mContext = context;
		this.mlistener = mlistener;
		this.imgArrayReference = imageArray;
		fnCreate();
	}
	
	public void show() {
		alert.show();
	}

	public void setTitle(String title) {
		this.alert.setTitle(title);
	}

	public void setMessage(String msg) {
		this.alert.setMessage(msg);
	}

	private void fnCreate() {
		alert = new AlertDialog.Builder(mContext);
		ListAdapter lap = new ImageListAdapter(mContext,imgArrayReference);
		
		DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int item) {
				// [0,1,2,3]
				mlistener.imgValue(item);
			}
		};
		
		alert.setAdapter(lap, listener);
	}
}